package org.lmind.brick.service;

import static org.ops4j.pax.exam.CoreOptions.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.lmind.brick.test.OsgiTestCase;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactorFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;


@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(EagerSingleStagedReactorFactory.class)
public class MyTestCase {
	
	@Configuration
	public Option[] config() {
		return OsgiTestCase.getConfig();
//		System.out.println("!!!!!!!!!!!My2TestCase");
//		Option debugOption = when(false)
//				.useOptions(
//						vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"));
//		return options(
//				frameworks(equinox().version("3.7.0")),
//				debugOption,
//				mavenBundle("org.lmind.brick", "org.lmind.brick.lib").version("0.0.1-SNAPSHOT"),
//				mavenBundle("org.lmind.brick", "org.lmind.brick.test").version("0.0.1-SNAPSHOT"),
//				systemProperty("maven.home").value(
//						"D:\\bin\\apache-maven-3.0.1"));
	}

	@Test
	public void test1(BundleContext context) {
		
		for (Bundle bundle : context.getBundles()) {
			System.out.println(bundle.getSymbolicName());
		}

		context.addBundleListener(new BundleListener() {

			@Override
			public void bundleChanged(BundleEvent event) {

			}
		});

		context.addServiceListener(new ServiceListener() {

			@Override
			public void serviceChanged(ServiceEvent event) {

			}
		});

		System.out.println("hello world");

	}
}
